function starttest() {
    //进入测试，隐藏封面
    document.getElementById('mybody1').style.display = "none";
    show_testing(rank);
    document.getElementById('mybody2').style.display = "";
}

function rstarttest() {
    document.getElementById('mybody1').style.display = "";
    score = 0;
    rank = 0;
    document.getElementById('mybody2').style.display = "none";
    document.getElementById('mybody3').style.display = "none";
}

function testing(n) {
    score += Number(n);
    if (total - 1 == rank) {
        document.getElementById('mybody2').style.display = "none";
        document.getElementById('mybody3').style.display = "";
        $("#selfchecking_score1").html(score);
        $("#selfchecking_score2").html(score);
        var data = {
            id: id,
            score: score
        }
        $.ajax({
            type: 'post',
            url: '/selfchecking-score/by_id_score',
            contentType: "application/json",
            data: JSON.stringify(data),
            success: function (res_description) {
                $("#selfchecking_result").html(res_description);
            },
            error: function () {
                $("#selfchecking_result").html("服务端请求失败稍后再试");
            }
        });

    } else {
        show_testing(++rank);
    }
}

function show_testing(rank) {
    $("#myprogress").css("width", rank / total * 100 + '%');
    var mycontents = selfcheckings.contents;
    var html = '';
    $("#mytitle").html(mycontents[rank]['head']);
    for (let j = 0; j < mycontents[rank]['options'].length; j++) {
        html += '<input type="radio" name="radio" onchange="testing(' + (j + 1) + ')">' + mycontents[rank]['options'][j] + '<br>';
    }
    $("#myoption").html(html);
}
